package com.billsystem.util;

import lombok.Data;
import lombok.experimental.Accessors;
//成功失败统一返回
@Data
@Accessors(chain = true)
public class Result {
    public static int SUCCESS_CODE = 0;
    public static int FAIL_CODE = 1;

    int code;
    String message;
    Object data;

    private Result(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
    //无需参数的成功
    public static Result success() {
        return new Result(SUCCESS_CODE,null,null);
    }
    //需要参数的成功
    public static Result success(Object data) {
        return new Result(SUCCESS_CODE,"",data);
    }
    //失败
    public static Result fail(String message) {
        return new Result(FAIL_CODE,message,null);
    }

}